home *** CD-ROM | disk | FTP | other *** search
/ PC Player 2004 May / pc player 2004-05.iso / Demos / FarCry / Data1.cab / _435DCF4CCCEC445F9230B96CCCF761B0 < prev    next >
Encoding:
Text File  |  2004-01-06  |  1.3 KB  |  41 lines

  1. // ===============================================================
  2. // Vertex Program: 
  3. // Description: 
  4. // Last Update: 14/08/2003
  5. // Coder: Andrey Honich
  6. // ===============================================================
  7.  
  8.       #include "../CGVPMacro.csi"
  9.  
  10.  
  11.       VertAttributes { POSITION_3 TANG_3X3 TEXCOORD0_2 }
  12.       
  13.       MainInput { VIEWPROJ_MATRIX, LIGHT_POS, CAMERA_POS }
  14.       DeclarationsScript
  15.       {
  16.         IN_T0_TANG
  17.         OUT_T0_T1_T2_T3
  18.       }
  19.       PositionScript = PosCommon                 
  20.       CoreScript
  21.       {
  22.         OUT.Tex0.xy = IN.TexCoord0.xy;
  23.         OUT.Tex3.xy = IN.TexCoord0.xy;
  24.  
  25.         TANG_MATR
  26.  
  27.         // store normalized light vector
  28.         float3 lightVec = normalize(LightPos.xyz - vPos.xyz);
  29.         // transform light vector from object space to tangent space and pass it as a tex coords
  30.         OUT.Tex1.xyz = mul(objToTangentSpace, lightVec.xyz);
  31.  
  32.         // compute view vector
  33.         float3 viewVec = normalize(CameraPos.xyz - vPos.xyz);
  34.  
  35.         // compute half angle vector
  36.         float3 halfAngleVector = normalize(lightVec + viewVec);
  37.  
  38.         // transform half angle vector from object space to tangent space and pass it as a tex coords
  39.         OUT.Tex2.xyz = mul(objToTangentSpace, halfAngleVector);
  40.       }
  41.